#ifndef LUA_MPI_BUILDING
#define LUA_MPI_BUILDING
#include <luaMPI/config.h>
#include <vector>
#include <string>
#include <list>
#include <boost/mpi.hpp>


namespace mpi{// tolua_export
    typedef boost::mpi::request request;
    typedef std::list< request > request_list;
	namespace world{ // tolua_export
		int rank(void);  // tolua_export
		int size(void);  // tolua_export
		void barrier(void); // tolua_export
		template<class T>
		    void send(int dest, int tag, const T& value);
		template<class T>
		    void recv(int source, int tag, T& value);
		extern boost::mpi::communicator world;
		template<class T>
		    void broadcast(T& val, int root);

		template<class T>
			request isend(int dest, int tag, const T& value);
		template<class T>
			request irecv(int dest, int tag, T& value);

		/*///////////
		// tolua_begin
		//void broadcast(int, int);
		//void broadcast(double, int);
		//void broadcast(std::string, int);
		void broadcast(std::vector<double>&, int);

		 //void send(int dest, int tag, double values);
		 //void send(int dest, int tag, const int& value);
		 void send(int dest, int tag, const std::vector<double>& value );
		 //void send(int dest, int tag, const std::string& value);

		 //void recv(int dest, int tag, double& value);
		 //void recv(int dest, int tag, int& value);
		 void recv(int dest, int tag, std::vector<double>& value );
	     //void recv(int dest, int tag, std::string& value);

	     //request isend(int dest, int tag, double values);
		 //request isend(int dest, int tag, const int& value);
		 request isend(int dest, int tag, const std::vector<double>& value );
		 //request isend(int dest, int tag, const std::string& value);

		 //request irecv(int dest, int tag, double& values);
		 //request irecv(int dest, int tag, int& value);
		 request irecv(int dest, int tag, std::vector<double>& value );
	     //request irecv(int dest, int tag, std::string& value);
		 // tolua_end
		/*/////////////
	}; // tolua_export


	void wait_all( std::list<boost::mpi::request>& reqs );
	/*///////////
	// tolua_begin

	 class request{
	 };
	class request_list{
	    request_list();
	    void push_back( request );
	    void clear();
	};
	void wait_all( request_list& reqs );
	// tolua_end
	/////////*/////////////
}; // tolua_export

/*///////////
// tolua_begin
module mpi
{
 //    extern std::list< boost::mpi::request > var;
 //  void wait_all( request_list& reqs );
}
 // tolua_end
/*/////////////

#endif
